package cn.iocoder.yudao.module.erp.dal.mysql.finance.financein;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.finance.financein.vo.FinanceInPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.finance.financein.FinanceInDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 收入单 Mapper
 *
 * @author huey
 */
@Mapper
public interface FinanceInMapper extends BaseMapperX<FinanceInDO> {

    default PageResult<FinanceInDO> selectPage(FinanceInPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FinanceInDO>()
                .eqIfPresent(FinanceInDO::getBillNo, reqVO.getBillNo())
                .eqIfPresent(FinanceInDO::getLinkId, reqVO.getLinkId())
                .eqIfPresent(FinanceInDO::getLinkNo, reqVO.getLinkNo())
                .betweenIfPresent(FinanceInDO::getBillDate, reqVO.getBillDate())
                .eqIfPresent(FinanceInDO::getAmount, reqVO.getAmount())
                .eqIfPresent(FinanceInDO::getPayer, reqVO.getPayer())
                .eqIfPresent(FinanceInDO::getIncomeId, reqVO.getIncomeId())
                .eqIfPresent(FinanceInDO::getIncomeName,reqVO.getIncomeName())
                .eqIfPresent(FinanceInDO::getAccountId, reqVO.getAccountId())
                .eqIfPresent(FinanceInDO::getAccountName, reqVO.getAccountName())
                .eqIfPresent(FinanceInDO::getOperatorId, reqVO.getOperatorId())
                .likeIfPresent(FinanceInDO::getOperatorName, reqVO.getOperatorName())
                .eqIfPresent(FinanceInDO::getProjectId, reqVO.getProjectId())
                .likeIfPresent(FinanceInDO::getProjectName, reqVO.getProjectName())
                .eqIfPresent(FinanceInDO::getRemark, reqVO.getRemark())
                .eqIfPresent(FinanceInDO::getFile, reqVO.getFile())
                .betweenIfPresent(FinanceInDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FinanceInDO::getId));
    }

    default FinanceInDO selectByNo(String billNo){
        return selectOne(new LambdaQueryWrapperX<FinanceInDO>().eq(FinanceInDO::getBillNo, billNo));
    }
}